/**
 * Promisified sleep
 * @param timeout 时长
 * @param unit ms 或 second, 默认 ms (毫秒)
 */
export const sleep = (timeout: number, unit: 'ms' | 'second' = 'ms') => {
  const ms = unit === 'second' ? timeout * 1000 : timeout;
  return new Promise(resolve => setTimeout(resolve, ms));
};
